home *** CD-ROM | disk | FTP | other *** search
/ Creative Review 28 / Creative-Review-CD-ROM-28.iso / pc / kungfu / assets / game.dir / 00033_Script_anim class < prev    next >
Text File  |  1997-08-08  |  8KB  |  338 lines

  1. -- anim class
  2. -- -----------------------------------------------------------------------------
  3.  
  4. property ancestor
  5.  
  6. property anim
  7. property animcount
  8.  
  9. property drawlist
  10. property drawcount
  11.  
  12. property animflag
  13. property hideflag
  14.  
  15. property framenumber
  16.  
  17. property max
  18. property master
  19.  
  20. property gap
  21. property callback
  22.  
  23. -- property timetest
  24.  
  25. -- =============================================================================
  26. global gtime, gspeed
  27.  
  28. -- =============================================================================
  29. -- new method
  30. -- -----------------------------------------------------------------------------
  31. on new me, props
  32.   
  33.   mInit me, props
  34.   return me
  35.   
  36. end new
  37.  
  38. -- =============================================================================
  39. -- minit method
  40. -- -----------------------------------------------------------------------------
  41. on minit me, props
  42.   
  43.   -- put "in minit anim"
  44.   
  45.   set master = getaprop ( props, #master )
  46.   set max = getaprop ( props, #max )
  47.   set anim = getaprop ( props, #anim )
  48.   
  49.   set animcount = count ( anim ) 
  50.   set  hideflag = false
  51.   
  52.   set framenumber = 0
  53.   
  54.   -- set timetest = new ( script "time test class" )
  55.   
  56.   -- put "out minit anim" 
  57.   
  58. end minit
  59.  
  60. -- =============================================================================
  61. -- msetdraw method
  62. -- -----------------------------------------------------------------------------
  63. on msetdraw me, draws
  64.   
  65.   --  put "in msetdraw"
  66.   
  67.   set drawlist = draws
  68.   if max > count ( drawlist ) then put "** not enough draws for anim **"
  69.   set ancestor = getat ( drawlist, master )
  70.   set drawcount = count ( drawlist )
  71.   
  72.   --  put "out msetdraw"
  73.   
  74. end msetdraw
  75.  
  76. -- =============================================================================
  77. -- mstart method
  78. -- -----------------------------------------------------------------------------
  79. on mstart me, thecallback
  80.   
  81.   msetoffset me, point ( 0, 0 )
  82.   set framenumber = 0
  83.   set callback = thecallback
  84.   set animflag = true
  85.   
  86.   maddtask gtime, me, the timer
  87.   
  88.   --  put "out start anim class"
  89.   
  90. end mstart me
  91.  
  92. -- =============================================================================
  93. -- mdispose method
  94. -- -----------------------------------------------------------------------------
  95. on mdispose me
  96.   
  97.   put "in mdispose anim class"
  98.   
  99.   set anim = 0
  100.   set ancestor = 0
  101.   set callback = 0
  102.   mdeletetasks gtime, me
  103.   
  104.   put "in mdispose anim class"
  105.   
  106. end mdispose me
  107.  
  108.  
  109. -- =============================================================================
  110. -- finish method
  111. -- -----------------------------------------------------------------------------
  112. on mfinish me
  113.   
  114.   --  put "in finish anim"
  115.   
  116.   set animflag = false
  117.   
  118.   if hideflag then 
  119.     --    put "hiding at mfinish anim"
  120.     mhide ( me )
  121.   end if
  122.   
  123.   set thecallback = callback
  124.   set callback = 0
  125.   if objectp ( thecallback ) then manimfinish ( thecallback , me )
  126.   
  127.   --  put "out finish anim"
  128.   
  129. end mfinish
  130.  
  131. -- =============================================================================
  132. -- mdotask method
  133. -- -----------------------------------------------------------------------------
  134. on mdotask me
  135.   
  136.   --  put "in  mdotask anim"
  137.   
  138.   return manimate ( me )
  139.   
  140.   --  put "out mdotask anim"
  141.   
  142. end mdotask 
  143.  
  144. -- =============================================================================
  145. -- mabort method
  146. -- -----------------------------------------------------------------------------
  147. on mabort me
  148.   
  149.   --  put "in mabort anim class :" , me
  150.   
  151.   set callback = false
  152.   mfinish me
  153.   mhide me
  154.   mdeletetasks gtime, me
  155.   
  156.   --  put "out mabort anim class :" , me
  157.   
  158. end mstop me
  159.  
  160. -- =============================================================================
  161. -- manimate method
  162. -- -----------------------------------------------------------------------------
  163. on manimate me
  164.   
  165.   -- put "in manimate anim"
  166.   
  167.   set framenumber = framenumber + 1
  168.   
  169.   --  put me
  170.   
  171.   -- put framenumber
  172.   
  173.   set frame = getat (anim, framenumber)
  174.   set gap = getpropat (anim, framenumber)
  175.   
  176.   -- put frame
  177.   
  178.   -- mtest timetest, gap
  179.   
  180.   set spritecount = count (frame)
  181.   
  182.   -- put spritecount
  183.   
  184.   repeat with spriteindex = 1 to spritecount
  185.     
  186.     set drawindex = getpropat ( frame, spriteindex )
  187.     set draw = getat ( drawlist, drawindex )
  188.     
  189.     set atomlist = getat ( frame, spriteindex )
  190.     set atomcount = count ( atomlist )
  191.     
  192.     -- put spriteindex , atomlist
  193.     
  194.     repeat with atomindex = 1 to atomcount
  195.       
  196.       set data = getat ( atomlist , atomindex )
  197.       
  198.       case ( getpropat ( atomlist , atomindex ) ) of
  199.         #hit:
  200.           -- put "hit!"
  201.           mhit callback, data
  202.         #offset: 
  203.           -- put "offset"
  204.           msetoffset  draw, data 
  205.         #cast: 
  206.           -- put "cast"
  207.           msetcastnumber  draw, data 
  208.         #finish:
  209.           -- put "finish"
  210.           mfinish me
  211.           return false
  212.       end case
  213.       
  214.     end repeat
  215.     
  216.     mdraw draw
  217.     
  218.   end repeat
  219.   
  220.   
  221.   --  put "out manimate anim"
  222.   
  223.   return gap
  224.   
  225. end manimate
  226.  
  227. -- =============================================================================
  228. -- manimate method
  229. -- -----------------------------------------------------------------------------
  230. on mshow me
  231.   
  232.   put "in mshow anim"
  233.   
  234.   repeat with index = 1 to max
  235.     set draw = getat ( drawlist, index )
  236.     put draw
  237.     puto draw
  238.   end repeat
  239.   
  240.   
  241.   put "out mshow anim"
  242.   
  243. end mshow
  244.  
  245. -- =============================================================================
  246. -- draw class patch batch methods
  247.  
  248. -- =============================================================================
  249. -- msetloc method
  250. -- -----------------------------------------------------------------------------
  251. on msetloc me, theloc
  252.   
  253.   --  put "in msetloc anim batch patch"
  254.   
  255.   repeat with index = 1 to drawcount
  256.     set draw = getat ( drawlist, index )
  257.     msetloc draw, theloc
  258.   end repeat
  259.   
  260.   --  put "out msetloc anim batch patch"
  261.   
  262. end msetloc
  263.  
  264. -- ==================================================
  265. -- msetoffset method
  266. -- --------------------------------------------------
  267. on msetoffset me, theloc
  268.   
  269.   --  put "in msetoffset anim batch patch : " , theloc
  270.   
  271.   repeat with index = 1 to max
  272.     set draw = getat ( drawlist, index )
  273.     msetoffset draw, theloc
  274.   end repeat
  275.   
  276. end msetoffset
  277.  
  278. -- ==================================================
  279. -- mmove method
  280. -- --------------------------------------------------
  281. on mmove me, theloc
  282.   
  283.   --  put "in mmove anim batch patch : " , theloc
  284.   
  285.   repeat with index = 1 to drawcount
  286.     set draw = getat ( drawlist, index )
  287.     mmove draw, theloc
  288.   end repeat
  289.   
  290. end mmove
  291.  
  292. -- ==================================================
  293. -- mhide method
  294. -- --------------------------------------------------
  295. on mhide me
  296.   
  297.   --  put "in mhide anim batch patch: " 
  298.   
  299.   repeat with index = 1 to drawcount
  300.     set draw = getat ( drawlist, index )
  301.     mhide draw
  302.   end repeat
  303.   
  304.   --  put "out mhide anim batch patch: " 
  305.   
  306. end mhide
  307.  
  308. -- ==================================================
  309. -- mdraw method
  310. -- --------------------------------------------------
  311. on mdraw me
  312.   
  313.   --  put "in mdraw anim batch patch"
  314.   
  315.   repeat with index = 1 to max
  316.     set draw = getat ( drawlist, index )
  317.     mdraw draw
  318.   end repeat
  319.   
  320. end mdraw
  321.  
  322. -- ==================================================
  323. -- msetcast method
  324. -- --------------------------------------------------
  325. on msetcast me, thecast
  326.   
  327.   put "in msetcast anim batch patch: " , thecast
  328.   
  329.   repeat with index = 1 to max
  330.     set draw = getat ( drawlist, index )
  331.     msetcast draw, thecast
  332.   end repeat
  333.   
  334. end msetcast me
  335.  
  336.  
  337.  
  338.